# cmake最低版本号要求
cmake_minimum_required(VERSION 3.0.0)
# 设置PROJECT_NAME变量
set(PROJECT_NAME demo)

project(${PROJECT_NAME} VERSION 3.6.0)

# 设置CPP的标准库为-std=c++11
SET(CMAKE_CXX_STANDARD 11)


# 添加头文件
include_directories(
    ${PROJECT_SOURCE_DIR}/3rd_party/easemob-sdk/include
    ${PROJECT_SOURCE_DIR}/include
)


# 链接静态库
if(APPLE)
	message(STATUS "current is mac os")
	# 链接SDK的库文件
	link_directories(
		${PROJECT_SOURCE_DIR}/3rd_party/easemob-sdk/lib/darwin
	)
elseif(WIN32)
	message(STATUS "current is windows os")
	# 链接SDK的库文件
	link_directories(
		${PROJECT_SOURCE_DIR}/3rd_party/easemob-sdk/lib/win64
	)
	# 在链接库->输入 添加 easemob.lib
	set(EXTERN_LIBRARY
		easemob.lib
	)
elseif(UNIX)
	message(STATUS "current is linux os, Architecture: ${CMAKE_SYSTEM_PROCESSOR}")
	# link sdk
	link_directories(
		${PROJECT_SOURCE_DIR}/3rd_party/easemob-sdk/lib/linux/${CMAKE_SYSTEM_PROCESSOR}/	
	)
else()
	message(STATUS "current is other os, maybe is linux os")
endif()
	




# 添加一个可编译的目标到工程
add_executable(${PROJECT_NAME} 
    src/main.cpp
	src/baseconfig.cpp
	src/simpledemo.cpp
	src/groupdemo.cpp
	src/chatroomdemo.cpp
	src/metadatademo.cpp
	src/presencedemo.cpp
)

if(APPLE)
	message(STATUS "current is mac os")
	#链接可执行文件和静态库
	target_link_libraries(${PROJECT_NAME}
			PRIVATE
			libeasemob.dylib
	)
elseif(WIN32)
	message(STATUS "current is windows os")
	#链接可执行文件和静态库
	target_link_libraries(${PROJECT_NAME} 
		PRIVATE
		easemob.lib
	)
	
	# 将SDK的动态库easemob.dll复制到exe所在目录下
	add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${PROJECT_SOURCE_DIR}/3rd_party/easemob-sdk/lib/win64/easemob.dll"  $<TARGET_FILE_DIR:${PROJECT_NAME}>)						  

 

	# 将demo作为默认启动项目
	set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT ${PROJECT_NAME})
elseif(UNIX)
	message(STATUS "current is linux os")
	#链接可执行文件和静态库
	target_link_libraries(${PROJECT_NAME} 
		PUBLIC
		-leasemob
		-lcrypto
		-lssl
	)

else()
	message(STATUS "current is other os")
endif()



